package com.example.index.arch.mvvm.di

import androidx.lifecycle.ViewModel
import com.example.index.arch.mvvm.model.LoginViewModel
import dagger.Binds
import dagger.MapKey
import dagger.Module
import dagger.multibindings.IntoMap
import kotlin.reflect.KClass

@MustBeDocumented
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.PROPERTY_GETTER,
    AnnotationTarget.PROPERTY_SETTER
)
@Retention(AnnotationRetention.RUNTIME)
@MapKey
annotation class ViewModelMapKey(val value: KClass<out ViewModel>)

@Module
abstract class ViewModelModule {


    @Binds
    @ViewModelMapKey(value = LoginViewModel::class)
    @IntoMap
    abstract fun bindLoginViewModel(vm: LoginViewModel): ViewModel
}